home *** CD-ROM | disk | FTP | other *** search
- /*
- File: FWOrdCol.h
-
- Contains: Definition of class FW_CPrivOrderedCollection
-
- Written by: Richard Rodseth
-
- Copyright: © 1993-94 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 10/24/94 jpa first checked in
- <6> 6/20/94 RR ODMemoryHeap* -> ODMemoryHeapID
- <5> 6/14/94 RR Added forward declaration ODMemoryHeap
- <4> 6/9/94 RR Remove ASLM stuff
- <2> 5/10/94 RR Removed ASLM_COMPATIBLE/CDECL
- <1> 5/5/94 CG first checked in
- <9> 3/15/94 MB Changes to support SCpp/ASLM builds,
- #1150864.
- <8> 2/9/94 TÇ add a couple of explicit "virtual" to the
- class declaration to pacify ASLM
- <7> 2/7/94 JA Tiger Team Makeover!
- <6> 2/2/94 NP Added support for allocating internal
- structures in given heap.
- <5> 12/7/93 NP Added helpful comments, because PEOPLE
- AREN'T COMMENTING HEADER FILES!!!!!
- <4> 11/19/93 PH ASLM fix - add class id for FW_CPrivValueLink
- <3> 11/19/93 NP Add definition of FW_CPrivValueLink to here (to
- allow subclassing.)
- <1> 8/13/93 RCR first checked in
-
- To Do:
- */
-
- #ifndef FWORDCOL_H
- #define FWORDCOL_H
-
- #ifndef FWLIST_H
- #include "FWList.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //==============================================================================
- // Theory of Operation
- //==============================================================================
-
- // OrdereCollection is an ordered collection of elements of type void* (since
- // we can't use templates)
- // Duplicates are allowed.
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- //==============================================================================
- // Scalar Types
- //==============================================================================
-
- typedef void* FW_ElementType;
-
- //=====================================================================================
- // Classes defined in this interface
- //=====================================================================================
-
- class FW_CLASS_ATTR FW_CPrivOrderedCollection; // An ordered (not sorted) collection of ElementTypes
- class FW_CLASS_ATTR FW_COrderedCollectionIterator;
-
- //=====================================================================================
- // Classes used by this interface
- //=====================================================================================
-
- class FW_CLASS_ATTR FW_CPrivValueLink; // A link plus a value of type FW_ElementType.
-
- //=====================================================================================
- // Global Variables
- //=====================================================================================
-
- //=====================================================================================
- // Class FW_CPrivValueLink - Definition
- //=====================================================================================
-
- class FW_CLASS_ATTR FW_CPrivValueLink : public FW_CPrivLink {
-
- public:
- FW_CPrivValueLink(FW_ElementType value);
- virtual ~FW_CPrivValueLink();
- FW_ElementType GetValue() { return fValue;}
- void SetValue(FW_ElementType v) { fValue = v;}
-
- private:
- FW_ElementType fValue;
- };
-
- //=====================================================================================
- // Class FW_CPrivOrderedCollection
- //=====================================================================================
-
- class FW_CLASS_ATTR FW_CPrivOrderedCollection
- {
-
- public:
-
- FW_CPrivOrderedCollection();
- FW_CPrivOrderedCollection(void* where);
- virtual ~FW_CPrivOrderedCollection();
-
- unsigned long Count() const { return fImplementation.Count(); };
-
- virtual void AddFirst(FW_ElementType element);
- virtual void AddLast(FW_ElementType element);
- virtual void AddBefore(FW_ElementType existing, FW_ElementType tobeadded);
- virtual void AddAfter(FW_ElementType existing, FW_ElementType tobeadded);
-
- virtual FW_ElementType After(FW_ElementType existing);
- virtual FW_ElementType Before(FW_ElementType existing);
-
- virtual FW_ElementType First();
- // Returns kODNULL if there is no first element.
- virtual FW_ElementType Last();
-
- virtual FW_ElementType RemoveFirst();
- // Don't call if there are no elements. Crash will result.
- virtual FW_ElementType RemoveLast();
- virtual void RemoveAll();
-
- // Called from the destructor. Removes all elements, deleting the links
- // Does not delete the elements themselves
-
- /*
- // Too dangerous because elements destructor is not called
- virtual void DeleteAll();
-
- // Removes and deletes all elements
- */
-
- virtual void Remove(FW_ElementType existing);
- virtual FW_Boolean Contains(FW_ElementType existing);
-
- virtual FW_COrderedCollectionIterator* CreateIterator();
-
- protected:
- virtual FW_CPrivValueLink* CreateNewLink(FW_ElementType value) const;
- virtual FW_Boolean ElementsMatch(FW_ElementType v1,FW_ElementType v2) const;
- // Does a pointer comparison by default
-
- private:
- FW_CPrivLinkedList fImplementation;
- void* fHeap;
- // ODMemoryHeapID fHeap; // if kODNULL, use default heap.
-
- friend class FW_COrderedCollectionIterator;
- friend class ListIterator;
- };
-
- //=====================================================================================
- // Class FW_COrderedCollectionIterator
- //=====================================================================================
-
- class FW_CLASS_ATTR FW_COrderedCollectionIterator {
- public:
- FW_COrderedCollectionIterator(FW_CPrivOrderedCollection* collection);
- ~FW_COrderedCollectionIterator();
- FW_ElementType First();
- FW_ElementType Next();
- FW_ElementType Last();
- FW_ElementType Previous();
- FW_Boolean IsNotComplete();
-
- private:
- FW_CPrivOrderedCollection* fCollection;
- FW_CPrivLinkedListIterator fImplementation;
- };
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif // FWORDCOL_H
-